package com.unipay.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @BelongsProject: SSM
 * @Author: cmy
 * @CreateTime: 2023-01-18  19:52
 * @Description: TODO
 */

@Controller
@RequestMapping("/test")
public class HelloController {

    @RequestMapping("/")
    public String protal(){
        // 将逻辑视图返回：逻辑视图 加 配置文件中的“视图前缀、视图后缀” = 物理视图
        return "index";
    }
//    @RequestMapping("/hello")
    @RequestMapping(value = {"/hello", "/val/hello"})
    public String success(){
        return "success";
    }

    @PostMapping
//    @RequestMapping(value = "/end", method = RequestMethod.POST)
    @RequestMapping(value = "/end")
    public String end(){
        return "end";
    }

    @RequestMapping(value = "/param0", params = {"password"}, headers = {"Referer"})
    public String param0(){
        return "param";
    }

    @RequestMapping(value = "/param", params = {"username=admin", "password"})
    public String param(){
        return "param";
    }

    @RequestMapping(value = "/a?t")
    public String ant(){
        return "end";
    }

    @RequestMapping(value = "/rest/{id}/{username}")
    public String rest(@PathVariable("id") Integer id, @PathVariable("username") String username){
        System.out.println("---------------");
        System.out.println("id: " + id + ", username: " + username);
        return "success";
    }
}
